{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Mails" %}{% endblock %}
{% block content %}
    <nav id="event-nav" class="header-nav">
        <div class="navigation">
            <div class="navigation-title">
                <h1>
                    {% blocktranslate count log_count=logs|length %}
                        Sent emails
                    {% plural %}
                        {{ log_count }} Sent emails
                    {% endblocktranslate %}
                </h1>
            </div>
            {% include "pretixcontrol/event/component_link.html" %}
        </div>
    </nav>
    <div>
        <ul class="list-group">
            {% for log in logs %}
                <li class="list-group-item logentry">
                    <p class="meta">
                        <span class="fa fa-clock-o fa-fw"></span> {{ log.datetime|date:"SHORT_DATETIME_FORMAT" }}
                        {% if log.user %}
                            <br/><span class="fa fa-user fa-fw"></span> {{ log.user.get_full_name }}
                        {% endif %}
                        {% if log.display %}
                            <br/><span class="fa fa-comment-o fa-fw"></span> {{ log.display }}
                        {% endif %}
                        <br/><span class="fa fa-tag fa-fw"></span> {% trans "Sent to orders:" %}
                        {% for status in log.parsed_data.sendto %}
                            {{ status }}{% if forloop.revcounter > 1 %},{% endif %}
                        {% endfor %}
                        {% if log.pdata.items %}
                            <br/><span class="fa fa-shopping-cart fa-fw"></span> {{ log.pdata.items|join:", " }}
                        {% endif %}
                        {% if log.pdata.filter_checkins %}
                            {% if log.pdata.not_checked_in %}
                                <br/><span class="fa fa-check-square-o fa-fw"></span> {% trans "All customers not checked in" %}
                            {% endif %}
                            {% if log.pdata.checkin_lists %}
                                <br/><span class="fa fa-check-square-o fa-fw"></span> {{ log.pdata.checkin_lists|join:", " }}
                            {% endif %}
                        {% endif %}
                        {% if log.pdata.subevent_obj %}
                            <br/><span class="fa fa-calendar fa-fw"></span> {{ log.pdata.subevent_obj }}
                        {% elif log.pdata.subevents_from %}
                            <br/><span class="fa fa-calendar fa-fw"></span> {{ log.pdata.subevents_from }} – {{ log.pdata.subevents_to }}
                        {% endif %}
                        {% if log.pdata.recipients == "attendees" %}
                            <br/><span class="fa fa-envelope fa-fw"></span> {% trans "Attendee contact addresses" %}
                        {% elif log.pdata.recipients == "both" %}
                            <br/><span class="fa fa-envelope fa-fw"></span> {% trans "All contact addresses" %}
                        {% else%}
                            <br/><span class="fa fa-envelope fa-fw"></span> {% trans "Order contact addresses" %}
                        {% endif %}
                    </p>
                    <p>
                        {% for locale, value in log.pdata.locales.items %}
                            <p>
                                <strong>[{{ locale }}] {% trans "Subject:" %} {{ value.subject }}</strong>
                            </p>
                            <pre>{{ value.message|linebreaksbr }}</pre>
                        {% endfor %}
                    </p>
                    <a href="{% url 'plugins:sendmail:send' organizer=request.event.organizer.slug event=request.event.slug %}?from_log={{ log.id }}">{% trans "Send a new email based on this" %}</a>
                </li>
            {% endfor %}
        </ul>
    </div>
    {% include "pretixcontrol/pagination.html" %}
{% endblock %}
